package org.test;

import java.io.File;

/**
 * <p>Project: day12 - cn.aix.Ex1</p>
 * <p>Powered by aix On 2023-07-24 10:09:08</p>
 * <p>描述：<p>
 *
 * @author aix [1305228917@qq.com]
 * @version 1.0
 * @since 17
 */
public class Ex1 {
    public static void main(String[] args) {
        //测试org.test.FileUtil.java 实现文件复制  将d:/c.jpg 文件复制到d:/okok/c.jpg
        FileUtil.copyFile(new File("d:/c.jpg"), "a.jpg");


        //实现目录复制
        //String wenjian = "d:/taa";
        //File file = new File(wenjian);
        //String Out = "D:\\test";
        //File file2 = new File(Out);
        //copydir(file, file2);
    }

    public static void copydir(File file, File Out) {
        if (!Out.exists()) {
            Out.mkdirs();
        }
        var ff = file.listFiles();
        for (File f : ff) {
            if (f.isDirectory()) {
                copydir(f, new File(Out, f.getName()));
            } else if (f.isFile()) {
                FileUtil.copyFile(f, Out.getAbsolutePath());
            }
        }
    }
}
